package common;

import java.util.ArrayList;

/**
 * This class represents a user with the following atributes:
 * 
 */
public class User {
    private String                  name;
    private String                  clientAddr;
    private int                     clientPort;
    private Boolean                 online;
    private ArrayList<Capabilities> capabilities;

    /**
     * Constructs a user.
     * 
     * @param name
     *            - User name
     * @param host
     *            - hostname or ip address
     * @param online
     *            - True or false
     * @param capacities
     *            - user capacities
     */
    public User(String name, String host, int port, Boolean online,
            Capabilities[] c) {
        this.name = name;
        this.clientAddr = host;
        this.clientPort = port;
        this.online = online;
        for (Capabilities cap : c)
            this.capabilities.add(cap);
    }

    /**
     * Return user name.
     * 
     * @return user.name
     */
    public String getName() {
        return name;
    }

    /**
     * Sets user name.
     * 
     * @requires name is String
     * @param name
     *            - user name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * Gets host name or IP address.
     * 
     * @return host name or IP address
     */
    public String getClientAddr() {
        return this.clientAddr;
    }

    public void setClientAddr(String clientAddr) {
        this.clientAddr = clientAddr;
    }

    /**
     * Gets user online status.
     * 
     * @return online status
     */
    public Boolean getOnline() {
        return online;
    }

    /**
     * Sets user online status.
     * 
     * @requires online = True || False.
     * @param online
     *            - user online status
     */
    public void setOnline(Boolean online) {
        this.online = online;
    }

    public int getClientPort() {
        return clientPort;
    }

    public void setClientPort(int clientPort) {
        this.clientPort = clientPort;
    }

    /**
     * Return string with user information.
     * 
     * @return String user information
     */
    public String toString() {
        return name + ":" + clientAddr + ":" + clientPort + ":"
                + online.toString();
    }

    public ArrayList<Capabilities> getCapabilities() {
        return capabilities;
    }

    public void setCapabilities(ArrayList<Capabilities> capabilities) {
        this.capabilities = capabilities;
    }
}
